home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG PD-ROM B4
/
PD-ROM B4.iso
/
Entertainment
/
Strategy
/
Robots
/
bot 1.0.1
/
Tutorial
/
ASM
/
Suicide
< prev
next >
Wrap
Text File
|
1991-06-25
|
2KB
|
107 lines
!
! Suicide
!
! This bot looks for other bots much like Bomber, except that
! when it sees another bot, it turns on its shield and charges
! at it full tilt.
!
#DATA
EQU incr 23
DEF SCN
DEF XX
DEF YY
DEF DAMAGE
DEF XVEL
DEF YVEL
#CODE ASM
RND 360, SCN
MOV D0, DAMAGE
RND 200, XX
ADD 25, XX
RND 200, YY
ADD 25, YY
:LOOP
CMP D0, DAMAGE
BEQ CONTINUE_LOOP
JSR MOVEAWAY
:CONTINUE_LOOP
ADD INCR, SCN
SCN SCN
CMP S0, 0
BEQ LOOP
JSR ATTACK
JSR MOVEAWAY
JMP LOOP
! In order to move at a given angle (here, the angle to the
! enemy bot), set velocity to (cos(angle), sin(angle)).
:ATTACK
COS S1
MOV R0, XVEL ! Results of math fns are in R0
SIN S1
VEL XVEL, R0
SHL 1 ! Turn on force shield
:ALOOP
CMP X1, 0
BNE ALOOP
CMP Y1, 0
BNE ALOOP
:endattack
SHL 0 ! Turn off force shield
RET
! The following subroutine is a bit different than the previous
! movement routines. Instead of moving *to* a point in the
! arena, the bot moves *toward* a point for 20 ticks. This
! risks smashing into walls (as the bot doesn't slow down), but
! it's easier to write than the other routine, and the bot
! won't completely choke if its treads are destroyed (as Bomber
! will -- it goes into an infinite loop trying to move to the
! specified point when the bot can no longer move at all).
:moveaway
NEG X0, XVEL
SUB XX, XVEL
MUL 10, XVEL
NEG Y0, YVEL
SUB YY, YVEL
MUL 10, YVEL
VEL XVEL, YVEL
NOP ! A quickie way to wait for 20 ticks
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
VEL 0, 0
MOV D0, DAMAGE
RND 200, XX ! Compute the new target point
ADD 25, XX
RND 200, YY
ADD 25, YY
RET
#END